﻿using System.Collections.Generic;

using BLToolkit.Data;
using BLToolkit.DataAccess;

using EMan.Common.WorkTasks;
using EMan.Server.Interface.DAL;

namespace EMan.DAL.Firebird
{
  public abstract class WorkTaskDalc : Dalc<WorkTask>, IWorkTaskDalc
  {
    [SqlQuery("select * from WorkTask")]
    public abstract IList< WorkTask > GetList();

    [SqlQuery("select * from WorkTask where (id = @id)")]
    public abstract WorkTask Get( int id );

    [ScalarSource(ScalarSourceType.AffectedRows)]
    [SqlQuery("insert into WorkTask (summary, fulltext, dueDate, employeeId) values( @summary, @fulltext, @dueDate, @employeeId) returning id, revision")]
    public abstract bool Insert( [Direction.OutputAttribute("id", "revision")] WorkTask entity );

    [ScalarSource(ScalarSourceType.AffectedRows)]
    [SqlQuery("update WorkTask set summary = @summary, fulltext = @fulltext, employeeId = @employeeId, dueDate=@dueDate where (id = @Id) and (revision = @Revision) returning id, revision")]
    public abstract bool Update( [Direction.InputOutput( "Revision" )] WorkTask entity );

    [ScalarSource(ScalarSourceType.AffectedRows)]
    [SqlQuery("delete from WorkTask where id = @id")]
    public abstract bool Delete( int id );

    [SqlQuery(@"select * from WorkTask where employeeId = @employeeId")]
    public abstract IList< WorkTask > GetListByEmployee(int? employeeId);
  }
}